<?php

use think\facade\Route;

// API路由组
Route::group('api', function () {
    // 认证相关路由
    Route::group('auth', function () {
        Route::post('login', 'auth/login');
        Route::post('register', 'auth/register');
        Route::get('info', 'auth/info');
        Route::post('refresh_token', 'auth/refreshToken');
        Route::post('logout', 'auth/logout');
        Route::post('change_password', 'auth/changePassword');
    });
    
    // 用户相关路由
    Route::group('user', function () {
        Route::get('', 'user/index');
        Route::get(':id', 'user/read');
        Route::post('', 'user/save');
        Route::put(':id', 'user/update');
        Route::delete(':id', 'user/delete');
    })->middleware(\app\middleware\JwtMiddleware::class);
    
    // 分类相关路由
    Route::group('category', function () {
        Route::get('', 'category/index');
        Route::get('all', 'category/all');
        Route::get(':id', 'category/read');
        Route::post('', 'category/save');
        Route::put(':id', 'category/update');
        Route::delete(':id', 'category/delete');
        Route::post('batch_delete', 'category/batchDelete');
    })->middleware(\app\middleware\JwtMiddleware::class);
    
    // 文章相关路由
    Route::group('article', function () {
        Route::get('', 'article/index');
        Route::get(':id', 'article/read');
        Route::post('', 'article/save');
        Route::put(':id', 'article/update');
        Route::delete(':id', 'article/delete');
        Route::post('batch_delete', 'article/batchDelete');
    })->middleware(\app\middleware\JwtMiddleware::class);
    
    // 标签相关路由
    Route::group('tag', function () {
        Route::get('', 'tag/index');
        Route::get('all', 'tag/all');
        Route::get(':id', 'tag/read');
        Route::post('', 'tag/save');
        Route::put(':id', 'tag/update');
        Route::delete(':id', 'tag/delete');
        Route::post('batch_delete', 'tag/batchDelete');
    })->middleware(\app\middleware\JwtMiddleware::class);
});